import {
  IconInvoicedWhite,
  IconInvoicingWhite,
  IconNotinvoicedWhite,
  ImgInvoicedColor,
  ImgInvoicingColor,
  ImgNotInvoicedColor,
} from "../utils/iconMap";
import BasicConfig from "../utils/config";

const _dfStyle = {
  "border-radius": "15rpx",
  padding: "6rpx 20rpx",
  "font-size": "28rpx",
  "white-space": "nowrap",
};

const _dfBtnStyle = {
  "border-radius": "100rpx",
  padding: "14rpx 0rpx",
  "min-width": "200rpx",
  "text-align": "center",
  "font-size": "32rpx",
  "white-space": "nowrap",
};

/**
 * 发票可操作动作
 */
export const invoiceAction = {
  /** 申请开票 */
  apply: "apply",
  /** 查看详情 */
  detail: "detail",
  /** 申请换开 */
  change: "change",
};

/**
 * 发票开票状态
 * 0.未开票
 * 1.开票中
 * 2.已开票
 */
export const invoiceStatus = {
  /** 未开票 */
  not: 0,
  /** 开票中 */
  doing: 1,
  /** 已开票 */
  final: 2,
};

export const invoiceStatusConfig = {
  [invoiceStatus.not]: {
    value: invoiceStatus.not,
    label: "未开票",
    icon: ImgNotInvoicedColor,
    detailIcon: IconNotinvoicedWhite,
    detailPriceLabel: "",
    style: {
      background: "#CCCCCC",
      color: "#ffffff",
    },
    getBtns: () => {
      const btns = [
        {
          key: invoiceAction.apply,
          label: "申请开票",
          value: invoiceAction.apply,
          style: {
            color: "#333333",
            border: "1px solid #CCCCCC",
            ..._dfBtnStyle,
          },
        },
        {
          key: invoiceAction.detail,
          label: "查看详情",
          value: invoiceAction.detail,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [invoiceStatus.doing]: {
    value: invoiceStatus.doing,
    label: "开票中",
    icon: ImgInvoicingColor,
    detailIcon: IconInvoicingWhite,
    detailPriceLabel: "预计开票金额",
    style: {
      background: "#208CEF",
      color: "#ffffff",
    },
    getBtns: () => {
      const btns = [
        {
          key: invoiceAction.detail,
          label: "查看详情",
          value: invoiceAction.detail,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
  [invoiceStatus.final]: {
    value: invoiceStatus.final,
    label: "已开票",
    icon: ImgInvoicedColor,
    detailIcon: IconInvoicedWhite,
    detailPriceLabel: "已开发票金额",
    style: {
      background: "#00B07B",
      color: "#ffffff",
    },
    getBtns: () => {
      const btns = [
        {
          key: invoiceAction.change,
          label: "申请换开",
          value: invoiceAction.change,
          style: {
            color: "#333333",
            border: "1px solid #CCCCCC",
            ..._dfBtnStyle,
          },
        },
        {
          key: invoiceAction.detail,
          label: "查看详情",
          value: invoiceAction.detail,
          style: {
            color: "#ffffff",
            background: BasicConfig.MainColor,
            ..._dfBtnStyle,
          },
        },
      ];
      return btns;
    },
  },
};

/**
 * 发票类型
 * 1.增值税纸质普通发票
 * 2.增值税电子普通发票
 */
export const invoiceTypeEnum = {
  /** 增值税纸质普通发票 */
  paper: 1,
  /** 增值税电子普通发票 */
  online: 2,
};

export const invoiceTypeEnumConfig = {
  [invoiceTypeEnum.paper]: {
    value: invoiceTypeEnum.paper,
    label: "增值税纸质普通发票",
    style: {},
  },
  [invoiceTypeEnum.online]: {
    value: invoiceTypeEnum.online,
    label: "增值税电子普通发票",
    style: {},
  },
};

/**
 * 抬头类型
 * 1.个人
 * 2.企业
 */
export const headerTypeEnum = {
  /** 个人 */
  person: 1,
  /** 企业 */
  company: 2,
};

export const headerTypeEnumConfig = {
  [headerTypeEnum.person]: {
    value: headerTypeEnum.person,
    label: "个人",
    style: {},
  },
  [headerTypeEnum.company]: {
    value: headerTypeEnum.company,
    label: "企业",
    style: {},
  },
};
